<script>
    $(function () {
      $.validator.setDefaults({
          highlight: function(element) {
              $(element).addClass('validate-input-error');
          },
          unhighlight: function(element) {
              $(element).removeClass('validate-input-error');
          },
          focusCleanup: true
      });
    })

    </script>
    <script>
//<![CDATA[

      
  $(function(){
    var addressSelectesView = new IkcrmWww.Views.Shared.AddressSelectsView({el: "#address-selectes"});

    jQuery.validator.addMethod("email_exists", function(value, element, params) {
      if (value != "") {
        result = false;

        $.ajax({
          url: "/users/exists.json",
          type: "post",
          async: false,
          beforeSend: function(xhr) {xhr.setRequestHeader('X-CSRF-Token', $('meta[name="csrf-token"]').attr('content'))},
          data: {
                  user: {email: $("#user_email").val()}
                },
          type: 'post',
          success: function(data, status) {
            if (data.code == '0') {
              result = true
            }
          }
        });

        return result;

      }
      return false;
    }, "此邮箱已经被注册，请更换邮箱")

    $new_user_validator = $('form.fill_info_form').validate({
      errorElement: 'span',
      errorClass: 'validate-info-error',
      onsubmit: true
    });
  });


//]]>
</script>